<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * 获取app配置 测试类
 */
namespace app\test\controller;

use app\utils\BoyeService;
use app\test\controller\Ava;
class Config extends Ava{
    //接口配置
    public function app(){
        if(IS_AJAX){

            $data = [
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Config_app',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);

        }else{
            $this->assign('type','BY_Config_app');
            $this->assign('field',[
                ['api_ver',101,LL('need-mark api version')],
            ]);
            echo $this->display('ava/test');
        }

    }

    //最新版本
    public function version(){
        if(IS_AJAX){
            $data = [
                'app_type'  =>I('post.app_type',''),
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Config_version',
            ];
            $service = new BoyeService();
            $result = $service->callRemote("",$data,true);
            echo $this->parseResult($result);

        }else{
            $this->assign('type','BY_Config_version');
            $this->assign('field',[
                ['api_ver',101,LL('need-mark api version')],
                ['app_type','ios',LL('need-mark app-type')],
            ]);
            echo $this->display('ava/test');
        }

    }

    // public function force_refresh(){

    //     if(IS_POST){

    //         $data = array(
    //             'api_ver'=>$this->api_ver,
    //             'notify_id'=>$this->notify_id,
    //             'type'=>'BY_Config_force_refresh',
    //             'alg'=>'md5',
    //         );

    //         $service = new BoyeServiceApi();

    //         $result = $service->callRemote("",$data,true);

    //         $this->parseResult($result);

    //     }

    //     $this->display();
    // }
}